import React, {useEffect, useState} from 'react'
import {
  Form,
  Button,
  Select,
  Input,
  Popconfirm,
  Card,
  Modal,
  Row,
  Col,
  DatePicker,
  TreeSelect,
  Cascader,
  Upload,
  message,Rate
} from 'antd'
import {connect} from 'umi'
import {UploadOutlined} from '@ant-design/icons';
import {
  genderList,
  maritalList,
  socialTraineeStateArray,
  nationList,
  regionList,
  healthsList,
  yesOrNoList,
  inOrgList,
  jobLevelTypeList,
  channelList,
  probationDayList,
  websiteList,positionStarList
} from "@/utils/constant";
import styles from "@/pages/Info/Edit/style.less";
import {findItemByTree} from "@/utils/functions";
import {getJobByOrgId, updateInfo, getEmployeeById} from '../../service'
import EducationTableForm from "@/pages/Info/Edit/components/EducationTableForm";
import SocietyTableForm from "@/pages/Info/Edit/components/SocietyTableForm";
import InOrgNameTableForm from '@/pages/Info/Edit/components/InOrgNameTableForm'
import FamilyTableForm from '@/pages/Info/Edit/components/FamilyTableForm'
import RelativeRecords from '@/pages/Info/Edit/components/RelativeRecords'
import {getProfessionstyle} from '@/services/service';
import moment from 'moment'
import {getUploadUrl} from "@/utils/upload";

const formLayout = {
  labelCol: {span: 7},
}

const {Option} = Select
const FormItem = Form.Item

const colStyle = {
  xl: {
    span: 6,
    offset: 1,
  },
  lg: 8,
  md: 12,
  sm: 24,
  xs: 24,
}

const widthStyle = {
  marginBottom: 24,
  width: '100%'
}


const CreateForm = (props) => {

  const {onCancel, onSubmit, current, visible, infoModel, global = {}, loading} = props;
  const {options = {}} = global;
  const {orgTree = [], orgLine = [], orgSystem = [], jobLevel = []} = options;
  const [form] = Form.useForm();
  const [unitTree, setUnitTree] = useState(orgTree);
  const [jobList, setJobList] = useState([]);
  const [employeeId, setEmployeeId] = useState(null);
  const [hiredate, setHiredate] = useState(null);
  const [fileName, setFileName] = useState(null);
  const [imageList, setImageList] = useState({});
  const [professionalTypeList,setProfessionalTypeList] = useState([]);

  useEffect(() => {
    if (current) {
      getProfessionstyle().then(res =>{
        setProfessionalTypeList(res);
      });
      setEmployeeId(current.oid);
      current.birthday = current.birthday ? moment(current.birthday) : null;
      current.beginworkdate = current.beginworkdate ? moment(current.beginworkdate) : null;
      current.hiredate = current.hiredate ? moment(current.hiredate) : null;
      let {nativeplaceProvince, ...data} = current;
      form.setFieldsValue({
        ...data,orgId: parseInt(current.orgId),
        unitId: parseInt(current.unitId),
        positionStar:parseInt(current.positionStar)
      });
      setHiredate(moment(current.hiredate).format('YYYY-MM-DD'));
      onChangeOrgId(parseInt(current.orgId));
      current.unitId && getJobByOrgId(current.unitId).then((res) => {
        setJobList(res)
      });
      getEmployeeById(current.oid).then((res) => {
        setImageList({
          photoUrl: data.photoUrl ? [{ uid: '1', name: data.photoUrl.split('----')[1], status: 'done', url: data.photoUrl }] : [],
          idcardImgs: data.idcardImgs ? data.idcardImgs.map((item,index)=>({ uid: index, name: item.split('----')[1], status: 'done', url: item })) : [],
          dimissionUrl: data.dimissionUrl ? [{ uid: '1', name: data.dimissionUrl.split('----')[1], status: 'done', url: data.dimissionUrl }] : [],
          graduationUrl: data.graduationUrl ? [{ uid: '1', name: data.graduationUrl.split('----')[1], status: 'done', url: data.graduationUrl }] : [],
          degreeUrl: data.degreeUrl ? [{ uid: '1', name: data.degreeUrl.split('----')[1], status: 'done', url: data.degreeUrl }] : [],
          healthUrl: data.healthUrl ? [{ uid: '1', name: data.healthUrl.split('----')[1], status: 'done', url: data.healthUrl }] : [],
          oldSalaryRecordUrl: data.oldSalaryRecordUrl ? data.oldSalaryRecordUrl.map((item,index)=>({ uid: index, name: item.split('----')[1], status: 'done', url: item })) : [],
          credential: data.credential ? data.credential.map((item,index)=>({ uid: index, name: item.split('----')[1], status: 'done', url: item })) : [],
          attachments: data.attachments ? data.attachments.map((item,index)=>({ uid: index, name: item.split('----')[1], status: 'done', url: item })) : [],
        })
      })
    }
  }, [current]);

  const fileProps = {
    name: 'file',
    // listType:"picture-card",
    action: getUploadUrl(),
    data: {name: fileName,catlog:'personal'},
    beforeUpload(file) {
      if (file.size/1024 > 10000) {
        message.error(`上传文件大小不能超过10M！`);
        return false;
      }
      setFileName(file.name)
    },
  }

  const onFormCancel = () => {
    form.resetFields()
    onCancel()
  }

  const onSave = async () => {
    const fieldsValue = await form.validateFields()
    form.resetFields()
    let {...data} = fieldsValue;
    await updateInfo({
      ...data, oid: employeeId,
      photoUrl: imageList.photoUrl[0]?.response || imageList.photoUrl[0]?.url,
      idcardImgs: imageList.idcardImgs?.map(item => item.response || item.url),
      dimissionUrl: imageList.dimissionUrl[0]?.response || imageList.dimissionUrl[0]?.url,
      graduationUrl: imageList.graduationUrl[0]?.response || imageList.graduationUrl[0]?.url,
      degreeUrl: imageList.degreeUrl[0]?.response || imageList.degreeUrl[0]?.url,
      healthUrl: imageList.healthUrl[0]?.response || imageList.healthUrl[0]?.url,
      oldSalaryRecordUrl: imageList.oldSalaryRecordUrl?.map(item => item.response || item.url),
      credential: imageList.credential?.map(item => item.response || item.url),
      attachments: imageList.attachments?.map(item => item.response || item.url),
    })
    message.success('保存成功');
    form.resetFields()
    onCancel()
  }


  const filterOption = (input, option) => {
    return option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
  }

  const onChangeOrgId = (e) => {
    const item = findItemByTree(orgTree, e)
    setUnitTree(item ? item.children : [])
  }

  const onChangeUnitId = (e) => {
    getJobByOrgId(e).then((res) => {
      setJobList(res)
    })
  }

  const confirm = async () => {
    const fieldsValue = await form.validateFields()
    form.resetFields()
    let { ...data} = fieldsValue;
    onSubmit({
      ...data, oid: employeeId,
      photoUrl: imageList.photoUrl && imageList.photoUrl[0]?.response || imageList.photoUrl[0]?.url,
      idcardImgs: imageList.idcardImgs?.map(item => item.response || item.url),
      dimissionUrl: imageList.dimissionUrl && imageList.dimissionUrl[0]?.response || imageList.dimissionUrl[0]?.url,
      graduationUrl: imageList.graduationUrl && imageList.graduationUrl[0]?.response || imageList.graduationUrl[0]?.url,
      degreeUrl: imageList.degreeUrl && imageList.degreeUrl[0]?.response || imageList.degreeUrl[0]?.url,
      healthUrl: imageList.healthUrl && imageList.healthUrl[0]?.response || imageList.healthUrl[0]?.url,
      oldSalaryRecordUrl: imageList.oldSalaryRecordUrl?.map(item => item.response || item.url),
      credential: imageList.credential?.map(item => item.response || item.url),
      attachments: imageList.attachments?.map(item => item.response || item.url),
    })
  };

  const onChangeImageList = (e, name) => {
    setImageList({
      ...imageList,
      [name]: e.fileList
    })
  };

  const uploadButton = (
    /*<div>
      <PlusOutlined />
      <div style={{ marginTop: 8 }}>上传图片</div>
    </div>*/
    <Button icon={<UploadOutlined/>}>点击上传文件</Button>
  );

  const renderContent = () => {
    return (
      <Row gutter={24}>
        <Col {...colStyle}>
          <FormItem label={'姓名'} name="name">
            <Input placeholder="请输入"/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'性别'} name="gender">
            <Select placeholder="请选择">
              {genderList.map((item, index) => {
                return (
                  <Option value={`${item.value}`} key={item.value}>
                    {item.label}
                  </Option>
                )
              })}
            </Select>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'身份证'} name="idcard">
            <Input placeholder="请输入"/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'民族'} name="nationality">
            <Select placeholder="请选择" showSearch filterOption={filterOption}>
              {nationList.map((item, index) => {
                return (
                  <Option value={`${item.value}`} key={item.value}>
                    {item.label}
                  </Option>
                )
              })}
            </Select>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'籍贯'} name="nativeplace" rules={[{required: true, message: '籍贯不能为空'}]}>
            <Input placeholder="请输入籍贯"/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'国籍'} name="nation">
            <Select placeholder="请选择" showSearch filterOption={filterOption}>
              {regionList.map((item, index) => {
                return (
                  <Option value={`${item.value}`} key={item.value}>
                    {item.label}
                  </Option>
                )
              })}
            </Select>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'政治面貌'} name="polity">
            <Select placeholder="请选择" showSearch filterOption={filterOption}>
              {inOrgList.map((item, index) => {
                return (
                  <Option value={`${item.value}`} key={item.value}>
                    {item.label}
                  </Option>
                )
              })}
            </Select>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'户口所在地'} name="regresidence">
            <Input placeholder="请输入"/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'家庭住址'} name="address">
            <Input placeholder="请输入"/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'健康状态'} name="healthstatus">
            <Select placeholder="请选择" showSearch filterOption={filterOption}>
              {healthsList.map((item, index) => {
                return (
                  <Option value={`${item.value}`} key={item.value}>
                    {item.label}
                  </Option>
                )
              })}
            </Select>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'电子邮箱'} name="privatemail">
            <Input placeholder="请输入"/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'生日'} name="birthday">
            <DatePicker placeholder="请选择日期" style={{width: '100%'}}/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'手机'} name="mobile">
            <Input placeholder="请输入"/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'参加工作时间'} name="beginworkdate">
            <DatePicker placeholder="请选择日期" style={{width: '100%'}}/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'婚姻状况'} name="marital">
            <Select placeholder="请选择">
              {maritalList.map((item, index) => {
                return (
                  <Option value={`${item.value}`} key={item.value}>
                    {item.label}
                  </Option>
                )
              })}
            </Select>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'是否退伍兵'} name="disbandment">
            <Select placeholder="请选择">
              {yesOrNoList.map((item, index) => {
                return (
                  <Option value={`${item.value}`} key={item.value}>
                    {item.label}
                  </Option>
                )
              })}
            </Select>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem label={'退伍军人编号'} name="veteranNum">
            <Input placeholder="请输入退伍军人编号"/>
          </FormItem>
        </Col>
        <Row gutter={24}>
          <Card title="任职信息" className={styles.card} bordered={false}>
            <Row gutter={16}>
              <Col {...colStyle}>
                <FormItem label={'公司'} name="orgId">
                  <TreeSelect disabled={true} treeData={orgTree} onChange={onChangeOrgId}/>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem label={'部门'} name="unitId">
                  <TreeSelect disabled={true} treeData={unitTree} onChange={onChangeUnitId}/>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem label={'职位'} name="jobId">
                  <Select disabled={true} placeholder="请选择" showSearch filterOption={filterOption}>
                    {jobList.map((item, index) => {
                      return (
                        <Option value={`${item.coidassignedjob}`} key={item.coidassignedjob}>
                          {item.cname}
                        </Option>
                      )
                    })}
                  </Select>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem label={'工作地点'} name="workAddress">
                  <Input disabled={true} placeholder="请输入"/>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem name="jobSystemId" label="体系">
                  <Select disabled={true} placeholder="请选择" showSearch filterOption={filterOption}>
                    {orgSystem.map((item, index) => {
                      return (
                        <Option value={`${item.id}`} key={item.id}>
                          {item.name}
                        </Option>
                      )
                    })}
                  </Select>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem name="lineId" label="条线">
                  <Select disabled={true} placeholder="请选择" showSearch filterOption={filterOption}>
                    {orgLine.map((item, index) => {
                      return (
                        <Option value={`${item.id}`} key={item.id}>
                          {item.name}
                        </Option>
                      )
                    })}
                  </Select>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem label={'工号'} name="code">
                  <Input disabled={true} placeholder="请输入"/>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem name="jobLevelType" label="职级类型">
                  <Select disabled={true} placeholder="请选择" showSearch filterOption={filterOption}>
                    {jobLevelTypeList.map((item, index) => {
                      return (
                        <Option value={item.value} key={item.value}>
                          {item.label}
                        </Option>
                      )
                    })}
                  </Select>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem name="jobLevelId" label="职级">
                  <Select disabled={true} placeholder="请选择" showSearch filterOption={filterOption}>
                    {
                      jobLevel.map((item, index) => {
                        return (
                          <Option value={`${item.id}`} key={item.name}>
                            {item.name}
                          </Option>
                        )
                      })
                    }
                  </Select>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem name="socialTrainee" label="招聘类型">
                  <Select disabled={true} placeholder="请选择">
                    {socialTraineeStateArray.map((item, index) => {
                      return (
                        <Option value={`${index}`} key={index}>
                          {item}
                        </Option>
                      )
                    })}
                  </Select>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem label={'入职日期'} name="hiredate">
                  <DatePicker disabled={true} placeholder="请选择日期" style={{width: '100%'}}/>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem name="probationday" label="试用期" rules={[{required: true, message: '试用期不能为空'}]}>
                  <Select disabled={true} placeholder="请选择" showSearch filterOption={filterOption}>
                    {probationDayList.map((item, index) => {
                      return (
                        <Option value={item.value} key={item.value}>
                          {item.label}
                        </Option>
                      )
                    })}
                  </Select>
                </FormItem>
              </Col>

              <Col {...colStyle}>
                <FormItem name="professionalType" label="专业类型" rules={[{required: true, message: '专业类型不能为空'}]}>
                  <TreeSelect treeData={professionalTypeList} placeholder="请选择专业类型"/>
                </FormItem>
              </Col>
              <Col {...colStyle}>
                <FormItem name="reinstatement" label="是否复职" rules={[{required: true, message: '是否复职不能为空'}]}>
                  <Select placeholder="请选择">
                    {yesOrNoList.map((item, index) => {
                      return (
                        <Option value={item.value} key={index}>
                          {item.label}
                        </Option>
                      )
                    })}
                  </Select>
                </FormItem>
              </Col>
              <Col {...colStyle}>
                <FormItem name="iscentreprincipal" label="是否中心负责人" rules={[{required: true, message: '是否中心负责人不能为空'}]}>
                  <Select placeholder="请选择">
                    {yesOrNoList.map((item, index) => {
                      return (
                        <Option value={item.value} key={index}>
                          {item.label}
                        </Option>
                      )
                    })}
                  </Select>
                </FormItem>
              </Col>
              <Col {...colStyle}>
                <FormItem name="isdepartmentprincipa" label="是否部门负责人" rules={[{required: true, message: '是否部门负责人不能为空'}]}>
                  <Select placeholder="请选择">
                    {yesOrNoList.map((item, index) => {
                      return (
                        <Option value={item.value} key={index}>
                          {item.label}
                        </Option>
                      )
                    })}
                  </Select>
                </FormItem>
              </Col>
              <Col {...colStyle}>
                <FormItem label='档案所在地' name="recordFileAddress">
                  <Input placeholder="请输入"/>
                </FormItem>
              </Col>
              <Col {...colStyle}>
                <FormItem label='档案编号' name="fileNumber">
                  <Input placeholder="请输入"/>
                </FormItem>
              </Col>
              <Col {...colStyle}>
                <FormItem label='岗位星级' name="positionStar">
                  <Select placeholder="请选择">
                    {positionStarList.map((item, index) => {
                      return (
                        <Option value={item.value} key={index}>
                          {item.label}
                        </Option>
                      )
                    })}
                  </Select>
                </FormItem>
              </Col>
            </Row>
          </Card>
        </Row>
        <Card title="招聘信息" className={styles.card} bordered={false} style={widthStyle}>
          <Row gutter={16}>
            <Col {...colStyle}>
              <FormItem label={'招聘渠道'} name="channel">
                <Select placeholder="请选择" showSearch filterOption={filterOption}>
                  {
                    channelList.map((item, index) => {
                      return (
                        <Option value={`${item.value}`} key={item.value}>
                          {item.label}
                        </Option>
                      )
                    })
                  }
                </Select>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem label={'推荐人(内部)'} name="innerReferrer">
                <Input placeholder="请输入"/>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem label={'推荐人(外部)'} name="outerReferrer">
                <Input placeholder="请输入"/>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem label={'招聘网站'} name="recruitmentWeb">
                <Select placeholder="请选择" showSearch filterOption={filterOption}>
                  {
                    websiteList.map((item, index) => {
                      return (
                        <Option value={item.value} key={item.value}>
                          {item.label}
                        </Option>
                      )
                    })
                  }
                </Select>
              </FormItem>
            </Col>
          </Row>
        </Card>
        <Card title="教育经历" bordered={false} style={widthStyle}>
          <FormItem name="employeeEducation">
            <EducationTableForm employeeId={employeeId}/>
          </FormItem>
        </Card>
        <Card title="工作经历" bordered={false} style={widthStyle}>
          <FormItem name="employeeSociety">
            <SocietyTableForm employeeId={employeeId}/>
          </FormItem>
        </Card>
        <Card title="行政党派信息" bordered={false} style={widthStyle}>
          <FormItem name="employeeInorgname">
            <InOrgNameTableForm employeeId={employeeId}/>
          </FormItem>
        </Card>
        <Card title="家庭成员信息" bordered={false} style={widthStyle}>
          <FormItem name="familyMember">
            <FamilyTableForm employeeId={employeeId}/>
          </FormItem>
        </Card>
        <Card title="关系报备" bordered={false} style={{ marginBottom: 24 }} style={widthStyle}>
          <FormItem name="RelativeRecordsEntity">
            <RelativeRecords oid={employeeId}/>
          </FormItem>
        </Card>

        <Card title="附件信息" bordered={false} style={widthStyle}>
          <Row gutter={24}>
            <Col span={8}>
              <FormItem labelAlign='right' wrapperCol={7} label='个人一寸照片'>
                <Upload {...fileProps} fileList={imageList.photoUrl} onChange={e => onChangeImageList(e, 'photoUrl')}>
                  {(!imageList.photoUrl || imageList.photoUrl.length < 1) && uploadButton}
                </Upload>
              </FormItem>
            </Col>

            <Col span={8}>
              <FormItem labelAlign='right' wrapperCol={7} label='身份证正反面照片'>
                <Upload {...fileProps} fileList={imageList.idcardImgs}
                        onChange={e => onChangeImageList(e, 'idcardImgs')}>
                  {(!imageList.idcardImgs || imageList.idcardImgs.length < 1) && uploadButton}
                </Upload>
              </FormItem>
            </Col>

            <Col span={8}>
              <FormItem labelAlign='right' wrapperCol={7} label='离职证明'>
                <Upload {...fileProps} fileList={imageList.dimissionUrl}
                        onChange={e => onChangeImageList(e, 'dimissionUrl')}>
                  {(!imageList.dimissionUrl || imageList.dimissionUrl.length < 1) && uploadButton}
                </Upload>
              </FormItem>
            </Col>

            <Col span={8}>
              <FormItem labelAlign='right' wrapperCol={7} label='毕业证'>
                <Upload {...fileProps} fileList={imageList.graduationUrl}
                        onChange={e => onChangeImageList(e, 'graduationUrl')}>
                  {(!imageList.graduationUrl || imageList.graduationUrl.length < 1) && uploadButton}
                </Upload>
              </FormItem>
            </Col>

            <Col span={8}>
              <FormItem labelAlign='right' wrapperCol={7} label='学位证'>
                <Upload {...fileProps} fileList={imageList.degreeUrl} onChange={e => onChangeImageList(e, 'degreeUrl')}>
                  {(!imageList.degreeUrl || imageList.degreeUrl.length < 1) && uploadButton}
                </Upload>
              </FormItem>
            </Col>

            <Col span={8}>
              <FormItem labelAlign='right' wrapperCol={7} label='体检报告'>
                <Upload {...fileProps} fileList={imageList.healthUrl} onChange={e => onChangeImageList(e, 'healthUrl')}>
                  {(!imageList.healthUrl || imageList.healthUrl.length < 1) && uploadButton}
                </Upload>
              </FormItem>
            </Col>

            <Col span={8}>
              <FormItem labelAlign='right' wrapperCol={7} label='银行流水/薪资证明'>
                <Upload {...fileProps} fileList={imageList.oldSalaryRecordUrl}
                        onChange={e => onChangeImageList(e, 'oldSalaryRecordUrl')}>
                  {(!imageList.oldSalaryRecordUrl || imageList.oldSalaryRecordUrl.length < 1) && uploadButton}
                </Upload>
              </FormItem>
            </Col>

            <Col span={8}>
              <FormItem labelAlign='right' wrapperCol={7} label='职称证书'>
                <Upload {...fileProps} fileList={imageList.credential}
                        onChange={e => onChangeImageList(e, 'credential')}>
                  {(!imageList.credential || imageList.credential.length < 1) && uploadButton}
                </Upload>
              </FormItem>
            </Col>

            <Col span={8}>
              <FormItem labelAlign='right' wrapperCol={7} label='其他附件'>
                <Upload {...fileProps} fileList={imageList.attachments}
                        onChange={e => onChangeImageList(e, 'attachments')}>
                  {(!imageList.attachments || imageList.attachments.length < 1) && uploadButton}
                </Upload>
              </FormItem>
            </Col>
          </Row>
        </Card>
      </Row>
    )
  }

  const renderFooter = () => {
    return (
      <>
        <Button onClick={() => onFormCancel()}>取消</Button>
        <Button onClick={() => onSave()}>保存</Button>
        <Popconfirm placement="leftTop"
                    title={`是否确认该员工${hiredate}入职?`}
                    onConfirm={confirm}
                    okText="是"
                    cancelText="否">
          <Button loading={loading} type="primary">确认</Button>
        </Popconfirm>
      </>
    )
  }

  return (
    <Modal
      width={'90%'}
      destroyOnClose
      title="编辑信息"
      visible={visible}
      footer={renderFooter()}
      onOk={confirm}
      onCancel={() => onFormCancel()}
      okText="确认"
      cancelText="取消"
    >
      <Form
        {...formLayout}
        form={form}
        style={{paddingTop: '24px'}}
      >{renderContent()}
      </Form>
    </Modal>
  )
}


export default connect(({infoAndEdit, infoModel, global}) => ({
  infoModel,
  infoAndEdit,
  global
}))(CreateForm)
